const Router = require('koa-router')
const router = new Router({ prefix: '/cart' })
const { auth } = require('../middleware/auth.middleware')
const { add, findAll, update, remove, selecAll, unselectAll } = require('../controller/cart.controller')
const { cartValidator } = require('../middleware/cart.middleware')

router.post('/', auth, cartValidator({ goods_id: "number" }), add)
router.get('/', auth, findAll)
router.patch('/:id', auth, cartValidator({
    number: { type: "number", required: false },
    selected: { type: 'bool', required: false }
}),
    update
)
router.delete('/', auth, cartValidator({ ids: 'array' }), remove)
router.post('/selectAll', auth, selecAll)
router.post('/unselectAll', auth, unselectAll)

// router.post('/', add)
// router.get('/', findAll)
// router.patch('/', update)
// router.delete('/', remove)

module.exports = router